<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<h2>总价格:{{totalPrice}}</h2>
		</div>
		<script src="../js/vue.js"></script>
		<script>
			const app=new Vue({
				el:'#app',
				data:{
					books:[{id:100,name:"编程",price:119},
					{id:101,name:"编程1",price:129},
					{id:102,name:"编程2",price:139},
					{id:103,name:"编程3",price:149},
					]
				},
				computed:{
					totalPrice(){
						let result=0;
						for(let i=0;i<this.books.length;i++){
							result+=this.books[i].price;
						}
						return result;
						/* for(let i in this.books){
							
						}
						
						for (let book of this.books) {
							
						} */
					}
				}
			})
		</script>
	</body>
</html>
